﻿using AutoMapper;
using ImoviesBlazor.Shared.Dtos;
using ImoviesBlazor.Shared.Entities;

namespace ImoviesBlazor.Server.Helpers
{
    /// <summary>
    /// AutoMapper配置类
    /// </summary>
    public class MyMappingProfile : Profile
    {
        public MyMappingProfile()
        {
            // 输出--------------------------------------------
            CreateMap<Teleplay, TeleplayDto>();
            CreateMap<Movie, MovieDto>();
            CreateMap<Animation, AnimationDto>();
            CreateMap<TeleplayVlink, TeleplayVlinkDto>();
            CreateMap<MovieVlink, MovieVlinkDto>();
            CreateMap<AnimationVlink, AnimationVlinkDto>();
            CreateMap<AnnualReview, AnnualReviewDto>();
            // 输出end-----------------------------------------


            // 输入--------------------------------------------
            CreateMap<TeleplayForCreateDto, Teleplay>();
            CreateMap<TeleplayForUpdateDto, Teleplay>();
            CreateMap<MovieForCreateDto, Movie>();
            CreateMap<MovieForUpdateDto, Movie>();
            CreateMap<AnimationForCreateDto, Animation>();
            CreateMap<AnimationForUpdateDto, Animation>();

            CreateMap<TeleplayVlinkForCreateDto, TeleplayVlink>();
            CreateMap<TeleplayVlinkForUpdateDto, TeleplayVlink>();
            CreateMap<MovieVlinkForCreateDto, MovieVlink>();
            CreateMap<MovieVlinkForUpdateDto, MovieVlink>();
            CreateMap<AnimationVlinkForCreateDto, AnimationVlink>();
            CreateMap<AnimationVlinkForUpdateDto, AnimationVlink>();

            CreateMap<AnnualReviewForCreateDto, AnnualReview>()
                .ForMember(dest => dest.VideoCate,
                    conf => conf.MapFrom(src => (uint)src.VideoCate));
            CreateMap<AnnualReviewForUpdateDto, AnnualReview>();
            // 输入end-----------------------------------------
        }
    }
}
